package com.th.supcom.pds.phamapply.client.widget.phamapplydetail;

import net.carefx.framework.container.client.constant.FrameworkConstants;

import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.DateTimePropertyEditor;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.th.supcom.pds.common.client.model.CodeConstants;
import com.th.supcom.pds.phamapply.client.model.InpPhamApplyDetailModel;

/**
 * 药品请领查询面板
 */
public class InpPhamApplySearchPanel extends FieldSet
{
    /** 清屏按钮. */
    private Button m_clearBtn;
    /** 摆药状态. */
    private ComboBox<InpPhamApplyDetailModel> m_dispenseIndicator;
    /** 开始时间框 */
    private DateField m_beginDate;
    /** 结束时间框 */
    private DateField m_endDate;
    /** 查询按钮. */
    private Button m_queryBtn;
    public InpPhamApplySearchPanel (String title)
    {
        setHeading (title);
        setHeight (45);
        init ();
    }

    
    public ComboBox<InpPhamApplyDetailModel> getDispenseIndicator ()
    {
    
        return m_dispenseIndicator;
    }


    public Button getClearBtn ()
    {
        return m_clearBtn;
    }



    public Button getQueryBtn ()
    {
        return m_queryBtn;
    }

    private void init ()
    {
        setLayout (new ColumnLayout ());
        final FormData formData = new FormData ("100%");
        // one
        final LayoutContainer one = new LayoutContainer ();

        FormLayout layout1 = new FormLayout ();
        layout1.setLabelAlign (LabelAlign.LEFT);
        layout1.setLabelWidth (80);
        one.setLayout (layout1);
        m_dispenseIndicator = new ComboBox<InpPhamApplyDetailModel> () ;
        m_dispenseIndicator.setEditable (false);
        m_dispenseIndicator.setTriggerAction (TriggerAction.ALL);
        m_dispenseIndicator.setDisplayField ("dispenseIndicatorName");
        ListStore <InpPhamApplyDetailModel>listStore=new ListStore <InpPhamApplyDetailModel> ();
        InpPhamApplyDetailModel model=new InpPhamApplyDetailModel();
        model.setDispenseIndicator ("B");
        model.setDispenseIndicatorName ("已分拣");
        InpPhamApplyDetailModel model2=new InpPhamApplyDetailModel();
        model2.setDispenseIndicator ("C");
        model2.setDispenseIndicatorName ("已发药");
        listStore.add (model);
        listStore.add (model2);
        m_dispenseIndicator.setStore (listStore);
        
        m_dispenseIndicator.setFieldLabel (FrameworkConstants.FORM_MUST_FILL_TIP + "摆药状态");
        add (one, new ColumnData (0.15));
        one.setStyleAttribute ("margin-right", "10px");
        one.add (m_dispenseIndicator, formData);

        final LayoutContainer begin = new LayoutContainer ();
        layout1 = new FormLayout ();
        layout1.setLabelAlign (LabelAlign.LEFT);
        layout1.setLabelWidth (55);
        begin.setLayout (layout1);
        m_beginDate = new DateField ();
        m_beginDate.setEditable (false);
        m_beginDate.setPropertyEditor (new DateTimePropertyEditor (CodeConstants.DATE_FORMAT_YYYY_MM_DD));
        m_beginDate.setFieldLabel ("开始时间");
        begin.add (m_beginDate);
        add (begin, new ColumnData (0.22));
        
        final LayoutContainer end = new LayoutContainer ();
        layout1 = new FormLayout ();
        layout1.setLabelAlign (LabelAlign.LEFT);
        layout1.setLabelWidth (15);
        end.setLayout (layout1);
        m_endDate = new DateField ();
        m_endDate.setEditable (false);
        m_endDate.setPropertyEditor (new DateTimePropertyEditor (CodeConstants.DATE_FORMAT_YYYY_MM_DD));
        m_endDate.setFieldLabel ("到");
        end.add (m_endDate);
        add (end, new ColumnData (0.20));
        
        final LayoutContainer two = new LayoutContainer ();
        final RowLayout layout2 = new RowLayout ();
        two.setLayout (layout2);

        m_queryBtn = new Button ("查询(Q)");
        m_queryBtn.setWidth (60);
        two.add (m_queryBtn);
        add (two, new ColumnData (0.08));

        final LayoutContainer five = new LayoutContainer ();
        final RowLayout layout5 = new RowLayout ();
        five.setLayout (layout5);
        m_clearBtn = new Button ("清屏(R)");
        m_clearBtn.setWidth (60);
        five.add (m_clearBtn);
        add (five, new ColumnData (0.08));
        setStyleAttribute ("padding-top", "3px");
        m_dispenseIndicator.focus ();
    }


    public void setClearBtn (final Button clearBtn)
    {
        m_clearBtn = clearBtn;
    }


    public void setQueryBtn (final Button queryBtn)
    {
        m_queryBtn = queryBtn;
    }


    public DateField getBeginDate ()
    {
    
        return m_beginDate;
    }


    public DateField getEndDate ()
    {
    
        return m_endDate;
    }

   
}
